﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		PageBinder.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 //   File:            PageBinder.cs
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion

using System;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Dexter.Web.Mvc.ViewModel.Resources;

namespace Dexter.Web.Mvc.ViewModel.Backoffice.Binders
{
	public class PageBinder
	{
		public int Id { get; set; }

		[Required(ErrorMessageResourceType = typeof(Errors), ErrorMessageResourceName = "RequiredField")]
		public string Title { get; set; }
		public string Abstract { get; set; }
		public string Slug { get; set; }

		[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd MMMM yyyy}")]
		public DateTime PublishDate { get; set; }
		
		public int PublishHour { get; set; }
		public int PublishMinutes { get; set; }

		[AllowHtml]
		[Required(ErrorMessageResourceType = typeof(Errors), ErrorMessageResourceName = "RequiredField")]
		public string FormattedBody { get; set; }
		
		public bool Publish { get; set; }

		[Required(ErrorMessageResourceType = typeof(Errors), ErrorMessageResourceName = "RequiredField")]
		public string Tags { get; set; }

		public int? ParentPageID { get; set; }

		public static PageBinder EmptyInstance()
		{
			return new PageBinder
			       {
			       		PublishDate = DateTime.Now ,
			       		PublishHour = DateTime.Now.Hour ,
			       		PublishMinutes = DateTime.Now.Minute,
						Publish = true
			       };
		}
	}
}
